﻿
using IBatisNet.DataAccess;
namespace curbside.IBatis
{
    /// <summary>
    /// DAO工厂类
    /// </summary>
    public class DaoFactroy
    {
        /// <summary>
        /// 私有构造函数
        /// </summary>
        private DaoFactroy() { }

        /// <summary>
        /// 得到指定数据库上下文的操作对象
        /// </summary>
        /// <typeparam name="T">数据库操作接口</typeparam>
        /// <typeparam name="contextName">数据库上下文名称</typeparam>
        /// <returns></returns>
        public static T GetContextDAO<T>(string contextName)
        {
            return (T)ServiceConfig.GetDaoManager(contextName).GetDao(typeof(T));
        }

        /// <summary>
        /// 得到指定数据库上下文的管理类
        /// </summary>
        /// <param name="contextName"></param>
        /// <returns></returns>
        public static IDaoManager GetDaoManager(string contextName)
        {
            return ServiceConfig.GetDaoManager(contextName);
        }
    }
}
